<div class="layuimini-container layuimini-page-anim">
    <!--<div class="layuimini-main">-->

    <!--<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>-->

    <!--<script type="text/html" id="currentTableBar">-->
    <!--{{# if(d.zt==0){ }}-->
    <!--<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">取消申请</a>-->
    <!--{{# }else{ }}-->
    <!--<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="application">申请看房</a>-->
    <!--{{# } }}-->
    <!--</script>-->

    <!--</div>-->
    <div><p style="margin: 20px;font-weight: bolder;font-size: 30px">在线预约看房</p></div>
    <form class="layui-form" action="" style="background: white;margin: 20px;padding: 10px">
        <div class="layui-form-item">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入姓名"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" lay-reqtext="用户名是必填项，岂能为空？" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-item" style="margin-top: 20px">
                <label class="layui-form-label">理想户型</label>
                <div class="layui-input-block">
                    <select name="interest" lay-filter="aihao">
                        <option value=""></option>
                        <option value="0">1室1厅1厨1卫</option>
                        <option value="1">2室2厅1厨1卫</option>
                        <option value="2">3室2厅1厨1卫</option>
                        <option value="3">2室1厅1厨1卫</option>
                        <option value="4">3室1厅1厨1卫</option>
                    </select>
                </div>
            </div>
        </div>
        <script>
            layui.use('form', function() { //此段代码必不可少
                var form = layui.form;
                form.render();
            });
        </script>


        <div class="layui-inline">
            <label class="layui-form-label">预约看房</label>
            <div class="layui-input-inline">
                <input type="text" name="date" id="date" lay-verify="date" placeholder="yy-MM-dd" autocomplete="off"
                       class="layui-input">
            </div>
            <div><p style="margin-top: 30px;font-weight: bolder;font-size: 15px">是否有指定置业顾问带看房</p></div>
            <div><p style="margin-top: 20px">如有则在其他栏填写置业顾问，谢谢您的支持！</p></div>
            <div class="layui-input-block" style="margin-left: 65px;margin-top: 10px">
                <input type="radio" name="sex" value="无" title="无">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">其他</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder=""
                           class="layui-input">
                </div>
                <script>

                    layui.use(['form', 'table', 'miniPage', 'element', 'layarea', 'laydate'], function () {
                        var $ = layui.jquery,
                            form = layui.form,
                            table = layui.table,
                            miniPage = layui.miniPage;
                        laydate = layui.laydate;
                        laydate.render({
                            elem: '#date'
                        });
                        laydate.render({
                            elem: '#date1'
                        });
                        table.render({
                            elem: '#currentTableId',
                            url: SURL + 'houses/queryHouseAll2',
                            toolbar: '#toolbarDemo',
                            defaultToolbar: ['filter', 'exports', 'print', {
                                title: '提示',
                                layEvent: 'LAYTABLE_TIPS',
                                icon: 'layui-icon-tips'
                            }],
                            cols: [[
                                // {type: "checkbox", width: 50},
                                {field: 'id', width: 80, title: 'ID', sort: true},
                                {field: 'numbers', width: 80, title: '房屋编号'},
                                {field: 'province', width: 80, title: '省'},
                                {field: 'city', width: 80, title: '市'},
                                {field: 'county', width: 80, title: '地区'},
                                {field: 'area', width: 80, title: '面积'},
                                {field: 'price', width: 80, title: '金额'},
                                {field: 'address', width: 180, title: '详细地址'},
                                {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
                            ]],
                            id: 'testReload',
                            limits: [10, 15, 20, 25, 50, 100],
                            limit: 10,
                            page: true,
                            skin: 'line'
                        });

                        $('.demoTable .layui-btn').on('click', function () {
                            var type = $(this).data('type');
                            active[type] ? active[type].call(this) : '';
                        });

                        function updatebyId(id, index) {
                            //向后台发送数据并进行添加操作
                            $.ajax({
                                url: SURL + "lookhouse/update?id=" + id,
                                type: "POST",
                                success: function (result) {
                                    if (result.code == 200) {
                                        debugger;
                                        layer.msg("取消成功", {
                                            icon: 6,
                                            time: 500
                                        }, function () {
                                            parent.window.location.reload();//重新页面
                                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                                            parent.layer.close(iframeIndex);
                                        });

                                    } else {
                                        layer.msg("取消失败");
                                    }
                                }
                            })
                            return false;
                        }

                        table.on('tool(currentTableFilter)', function (obj) {
                            var data = obj.data;
                            if (obj.event === 'application') {
                                var content = miniPage.getHrefContent('page/other/addLook.html');
                                var openWH = miniPage.getOpenWidthHeight();
                                var index = layer.open({
                                    title: '申请看房',
                                    type: 1,
                                    shade: 0.2,
                                    maxmin: true,
                                    shadeClose: true,
                                    area: ['60%', '60%'],
                                    content: content,
                                });
                                //把房子id渲染
                                $("#housesId").val(data.id);

                                $(window).on("resize", function () {
                                    layer.full(index);
                                });
                            } else if (obj.event === 'delete') {

                                layer.confirm('你真的要取消吗？', function (index) {
                                    console.log(data.lookId)
                                    updatebyId(data.lookId, index);
                                })
                            }
                        });


                    });
                </script>

            </div>
        </div>
        <div>
            <button style="margin-left: 150px">在线邀约</button>
        </div>
    </form>
</div>